package com.manli.api.controller;

import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParamsArea1;
import com.manli.api.pojo.QueryParamsPhone;
import com.manli.api.pojo.Result;
import com.manli.api.util.AliYunSmsUtil;
import com.manli.api.util.NumsUtil;
import com.manli.api.util.ObjectEmptyUtil;
import com.manli.api.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value="/phone", tags="手机验证码")
@RestController
@RequestMapping("api/phone")
public class PhoneCodeController {
    @Autowired
    private AliYunSmsUtil aliYunSmsUtil;

    @ApiOperation(value = "发送手机验证码",notes = "")
    @PostMapping("/sendSms")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_OPEN)
    public Result all(@RequestBody QueryParamsPhone phone)throws Exception{
        ObjectEmptyUtil.phoneIslegal(phone.getPhone());
        aliYunSmsUtil.sendSms(phone.getPhone(), NumsUtil.getFourNum());
        return ResultUtil.success();
    }
}
